<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<isperp:grid url="app/message/listDetails?all=1"
	autoReloadTreeMenu="myMessageMenu" gridId="messageReceiverGrid"
	cusDialogSize="normal" showSearchbar="true" showToolbar="true"
	ondbClickRowEvent="messageReceiverGrid.view(rowid)" actionsWidth="70"
	cusActions="messageActions(rowObject)" cusViewUrl="app/message/view">
	<jsp:attribute name="searchbar">
	<table class="search-table">

		<tr>
			<td class="td1">内容：</td>
			<td><input type="text" field="content" op="cn">
			<td class="td1">发送者：</td>
			<td><input type="text" field="sender_name" op="cn"></td>
			<td class="td1">接收者：</td>
			<td class="td2"　><input type="text" field="receiver_name"
				op="cn"></td>

		</tr>
		<tr>
			<td class="td1">发送时间：</td>
			<td class="td2" 　 colspan="5"><input type="text"
				field="create_date" op="gt">~<input type="text"
				field="create_date" op="lt">
		</tr>
	</table>
	</jsp:attribute>
	<jsp:attribute name="toolbar">
	<isperp:treeMenu id="myMessageMenu" targetGridId="messageReceiverGrid">
		<isperp:async enable="true" url="app/message/myMessageMenu"></isperp:async>
		<isperp:callback onClick="myMessageMenuTree_onNodeClick"
				onAsyncSuccess="myMessageMenuTree_onNodeClickFirst();">
		</isperp:callback>
	</isperp:treeMenu>
	 
	</jsp:attribute>
	<jsp:body>
	<isperp:column name="id" title="id" hidden="true"></isperp:column>
	
	<isperp:column name="readed" title="" width="35" isFormatterFun="true"
			formatter="return formatterReadedStatus(cellvalue);">
	</isperp:column>
	<isperp:column name="content" title="内容" width="380">
	</isperp:column>
	<isperp:column name="sender_name" title="发送者" width="80">
	</isperp:column>
	<isperp:column name="create_date" title="发送时间" width="110"> 
	</isperp:column>
	<isperp:column name="receiver_name" title="接收者" width="80">
	</isperp:column>
	</jsp:body>
</isperp:grid>
<script type="text/javascript">
	function messageActions(rowObject) {
		return isperp.createGridAction({
			title : '回复',
			iconCls : 'icon-change',
			onclick : "replayMessage('" + rowObject.id + "')"
		})
	};

	function replayMessage(rowid) {

		messageReceiverGrid.jqGrid.jqGrid('setCell', rowid, 'readed', "1");
		isperp.openDialog({
			title : '回复消息',
			contentUrl : "app/message/receiver/replyEdit?messageId=" + rowid
		});
	};

	function formatterReadedStatus(v) {

		if (v == "1") {

			return "<img src='img/icons/packs/fugue/24x24/mail-open.png'>";
		} else {
			return "<img src='img/icons/packs/fugue/24x24/mail.png'>";
		}

	};
</script>
